from operator import attrgetter


class User:
    def __init__(self, user_id):
        self.user_id = user_id

    def __repr__(self):
        return "User({})".format(self.user_id)


users = [User(45), User(34), User(98), User(23)]
users = sorted(users, key=attrgetter('user_id'))
print(users)
